import { Injectable } from '@angular/core';
import {HttpUtils} from "../utils/http.utils";
import {USER} from "./user.service";
import {ParamsModel, PageParam} from "../model/params.model";

@Injectable()
export class MeterService {
  meterListApi : string = '/meter';
  rechargeApi:string = '/bill'
  constructor(private api: HttpUtils,private USER:USER) {

  }

  getList(succ,contractId,page?:PageParam){
    let pm = new ParamsModel(this.USER);
    pm.url = this.meterListApi;
    pm.reqestData = page;
    pm.reqestData.contractId = contractId;
    pm.succCallback = succ;
    this.api.get(pm);
  }
  recharge(param,succ){
    let pm = new ParamsModel(this.USER);
    pm.url = this.rechargeApi;
    pm.reqestData = param;
    pm.succCallback = succ;
    this.api.post(pm);
  }
  getBalance(contractId,succ){
    let pm = new ParamsModel(this.USER);
    pm.url = `/meter/${contractId}`;
    pm.succCallback = succ;
    this.api.get(pm);
  }
}
